Stop find_c aborting on directory entries#4
Merged
Conversation
directory_entry::file_size() has no defined result for a directory. MSVC returns the size cached by FindFirstFile (0), so on Windows the throwing overloads used here never fire; libc++ calls stat and throws instead, so on macOS every NewFileSearch over a folder that contains a subdirectory died with "filesystem error: in file_size: Is a directory" before the binding could even apply its findDirectories filter. The build list was the visible casualty - one sub-folder under Builds/ made the startup screen unreachable - but Main.lua's folder copy/delete walks and the Export scripts glob directories the same way. Query the entry through the error_code overloads and report 0 for a directory, matching what Windows already returns. is_directory() and last_write_time() get the same treatment: they fail out of the same status() call, so an unreadable or dangling entry took the process down by the identical route.
pathanin
force-pushed
the
fix-filesearch-directory-file-size
branch
from
July 25, 2026 09:22
7ceff97 to
6b4cf07
Compare
Owner
Author
|
End-to-end confirmed on the staged arm64 runtime: the build list renders the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a macOS-only crash: opening the build list with a sub-folder under
Builds/throwsCause
find_c::FindFirst/FindNextcallediter->file_size()— the throwing overload — on every entry that matched the glob.directory_entry::file_size()has no defined result for a directory: MSVC returns the size cached byFindFirstFile(0) and never throws, libc++ callsstatand throws. So the code is correct on Windows and fatal everywhere else.The throw happens in
find_c, beforeNewFileSearch'sfindDirectoriesfilter atui_api.cpp:1354, so it is not limited to directory searches — anyNewFileSearch(dir.."*")dies ifdirholds a sub-directory. Affected call sites in PoB-PoE2:Modules/BuildListHelpers.lua:63,Classes/FolderListControl.lua:46,82,Classes/BuildListControl.lua:144,Modules/Main.lua:1583-1634(folder copy/delete walks),Export/Main.lua:712-763.Change
Query metadata through the
error_codeoverloads and report0for a directory — the value Windows already produces, so no caller sees a behaviour change.is_directory()andlast_write_time()get the same treatment: they fail out of the samestatus()call, so an unreadable or dangling entry aborted the process by the identical route.Verification
Windows CI cannot cover this — the divergence is libc++ vs MSVC. Verified locally against the shipped arm64 dylib with a probe that calls
find_c::FindFirst/FindNextdirectly oversrc/Builds/, which contains one sub-folder (testpob) and two files:RESULT: THREW - filesystem error: in file_size: Is a directory [.../Builds/testpob]on the first entrytestpob dir=1 size=0,.DS_Store dir=0 size=8196,~~temp~~.xml dir=0 size=53075;*.xmlglob returns 1; recursing intotestpob/*returns 2; no exceptionBuilt with the standard
arm64-osx-dynamicconfig; incremental relink, LuaJIT untouched so the soname is unchanged.runtime/libSimpleGraphic.dylibrestaged with@loader_pathre-added; all 9@rpathdeps resolve. Backup at~/Documents/pob-runtime-backup-2026-07-25/.A failed
last_write_time()returnsfile_time_type::min(), whose negative count would wrap to a huge value infind_c::modified(unsigned long long) and sort the entry to the top of the build list's "Sort by Last Edited"; that reports 0 instead.